<template>
  <el-cascader
    :options="options"
    v-model="selectedOptions"
    @change="handleChange"
    :disabled="disabled"
    size="small">
  </el-cascader>
</template>


<script>
  import {list2tree} from '@/utils/treeUtils';
  import {getOrgnazationList} from '@/api/companyBankAccount'
  import httpClient from '@/utils/httpClient';
  export default {
    data() {
      return {
        options: [],
        selectedOptions: [],
        list: []
      };
    },
    props: {
      addrParam: {
        default: ""
      },
      disabled: {
        default: false
      }
    },

    mounted(){
      this.$nextTick(function () {
        this.init()
      })
    },
    methods: {
      handleChange(value) {
        this.$emit('addrChange', this.selectedOptions);
      },
      init(){
        let _this = this;
        httpClient(getOrgnazationList, '', function (error, results) {

          console.log('results---', results.list)
          for (let i = 0; i < results.list.length; i++) {
            //console.log(results.list[i].orgTreeList[0].parentOrgId)
            let param = {
              parentId: results.list[i].orgTreeList[0].parentOrgId,
              id: results.list[i].orgnazation.id,
              value: results.list[i].orgnazation.id,
              label: results.list[i].orgnazation.name,
            }
            _this.list.push(param);
          }
          _this.options = list2tree(_this.list);
        });
      },
    },
  };
</script>
<style>
  .el-cascader--small .el-cascader__label {
    line-height: 36px;
  }
</style>
